class Solution {
public:
    int findContentChildren(vector<int>& g, vector<int>& s) {
        sort(g.begin(), g.end());
        sort(s.begin(), s.end());
        int ret = 0;
        int ret_max = min(g.size(), s.size());
        for (auto i : s)
        {
            if (ret >= ret_max) return ret;
            if (i >= g[ret]) ret++;
        }
        return ret;
    }
};